﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>YUNSPACE | 场地大师</title>
   

    <link rel="stylesheet" href="~/Content/css/style.3.2.0.css">
    <link rel="stylesheet" href="~/Content/css/login.css">
     <link href="~/Content/css/framework-font.css" rel="stylesheet" />
    <link href="~/Content/css/framework-login.css" rel="stylesheet" />
    <style>
        .login_tips {
            position: inherit;
            bottom: 10px;
            z-index: 99;
            width: 100%;
        }
    </style>
   
</head>
<body class=" login">
    <div class="menu-toggler sidebar-toggler"></div>
    <div class="logo clearfix">
        <div class="logo-block">
            <div class="login_logo_img">
                <img src="~/Content/img/logo_new_0427.png">
            </div>

        </div>
    </div>
    <div class="login_cover menu_hide">
        <div class="close_cover">x</div>
        <div class="alpha-bg">
        </div>
        <p>这个手机还未注册<br>点击下方注册按钮进行注册</p>
        <p style="margin-top:90px;"><a href="/Login/Register" class="btn green">注册</a></p>
    </div>
    <div class="content">
        <h3 class="form-title font-green">登录</h3>
        <div class="alerts alert-dangers display-hide error-block">
            <button class="closes" data-close="alert"></button>
            <span class="login_error_msg"></span>
        </div>
        <input type="hidden" class="login_ways" name="login_ways" value="auth_login">
        <div class="form-group">
            <label class="control-label visible-ie8 visible-ie9">手机号码</label>
            <input id="phone" class="form-control form-control-solid placeholder-no-fix phone" type="text" autocomplete="off" placeholder="手机号码" name="username">
        </div>
        <div class="form-group auth_login_l">
            <label class="control-label visible-ie8 visible-ie9">验证码</label>
            <input style="width: 50%" class="form-control form-control-solid placeholder-no-fix code-input pull-left code" type="text" autocomplete="off" placeholder="验证码" name="password" id="code">
            <button style="width: 50%" type="button" id="sendcode" class="btn btn-success  send-code pull-left sendcode-btn">获取短信验证码</button>
            <button id="submit" class="btn green uppercase login_btn"><span>登录</span></button>
            <div class="login_tips"></div>
            <p style="margin: 5px 0 20px 0;">
                <a href="/Login/Register" style="text-underline: none;float: left;">没有场地立即申请创建</a>
        </div>
        <p class="copyright">
            2018 ©
            <a href="http://www2.yunspace.com.cn/" title="云SPACE" target="_blank">YUNSPACE</a>
        </p>
    </div>
    <script src="~/Content/js/jquery/jquery-2.1.1.min.js"></script>
    <script>
        $(function () {
            $('#sendcode').click(function () {
                var obj = this;
                var Phone = $('#phone').val();
                if (Phone) {
                    $.ajax({
                        url: "/Login/SendCode",
                        data: { "Phone": Phone },
                        type: "post",
                        dataType: "json",
                        asyn: false,
                        success: function (data) {
                            if (data.state == "success") {
                               
                                console.log(data.message);
                                settime(obj);
                            }
                        }
                    });
                }               
            });

            $('#submit').click(function () {
                var Phone = $('#phone').val();
                var Code = $('#code').val();
                if (Phone || Code) {
                    $("#submit").attr('disabled', 'disabled').find('span').html("loading...");
                    $.ajax({
                        url: "/Login/CheckUser",
                        data: { "Phone": Phone, "Code": Code },
                        type: "post",
                        dataType: "json",
                        asyn: false,
                        success: function (data) {
                            if (data.state == "success") {
                                $("#submit").find('span').html("登录成功，正在跳转...");
                                setCache("DLXX", data.data);
                                window.setTimeout(function () {
                                    window.location.href = "/Home/Index";
                                }, 500);
                            } else {                                
                                $("#submit").removeAttr('disabled').find('span').html("登录");
                                formMessage(data.message);
                            }
                        }
                    });
                }
            });
        });

        var countdown = 60;

        function setCache(key, value) {
            localStorage.setItem(key, JSON.stringify(value || []));
        }

        function settime(obj) {
            if (countdown == 0) {
                obj.removeAttribute("disabled");
                obj.innerText = "获取短信验证码";
                countdown = 60;
                return;
            } else {
                obj.setAttribute("disabled", true);
                obj.innerText = "重新发送(" + countdown + ")";
                countdown--;
            }
            setTimeout(function () {
                settime(obj)
            }, 1000);
        }

        formMessage=function (msg) {
            $('.login_tips').find('.tips_msg').remove();
            $('.login_tips').append('<div class="tips_msg"><i class="fa fa-question-circle"></i>' + msg + '</div>');
        }
    </script>

</body>
</html>
